package com.xunji.xunji.module.account.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;

import com.huanxiao.base.base.BaseActivity;
import com.huanxiao.base.net.RespResult;
import com.xunji.xunji.R;
import com.xunji.xunji.module.account.bean.MyTrace;
import com.xunji.xunji.module.account.controller.UserAccount;
import com.xunji.xunji.module.account.ui.adapter.MyTraceAdapter;
import com.xunji.xunji.module.trace.mvp.model.TrackModel;
import com.xunji.xunji.net.ParamManager;

import java.util.List;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Paul on 2017/2/28.
 */

public class MyTraceActivity extends BaseActivity {
    private ListView listView;
    private TrackModel trackModel;

    public static void start(Context context) {
        Intent starter = new Intent(context, MyTraceActivity.class);
        context.startActivity(starter);
    }
    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_trace;
    }

    @Override
    protected void initPresenter() {
        trackModel = new TrackModel();

    }

    @Override
    public void initBundleExtras(Bundle extras) {

    }

    @Override
    protected void initView() {
        listView = fvById(R.id.lv_trace);
        trackModel.queryAllByUserId(ParamManager.queryList(UserAccount.getInstance().getUserInfo().getUserId(),1,20))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<RespResult<List<MyTrace>>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(RespResult<List<MyTrace>> respResult) {

                        MyTraceAdapter adapter = new MyTraceAdapter(respResult.getData());
                        listView.setAdapter(adapter);

                    }
                });
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    protected boolean isBindEventBus() {
        return false;
    }
}
